package com.indra.archetypeweb.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.indra.archetypeweb.service.UserService;

@Controller
@Secured({ "ROLE_USER", "ROLE_ADMIN" })
@RequestMapping(value = "/user")
public class UserController {

    private static final Logger LOG = LoggerFactory.getLogger(UserController.class);

    @Autowired
    private UserService userService;

    @RequestMapping(method = RequestMethod.GET)
    public String index(final UserDetails userDetails, final Model model) {
        LOG.info(userDetails.toString());
        model.addAttribute("user", userDetails.getUsername());
        return "user/index";
    }

}
